<%@ Page Language="VB" MasterPageFile="~/MasterPages/popup.master" AutoEventWireup="false" CodeFile="Chat.aspx.vb" Inherits="Chat" title="Untitled Page" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="uxContentPlaceHolder1" Runat="Server">

<table width="100%">
    <tr>
        <td valign="top">       
        
            <container:templatedcontainer id="uxTemplate" runat="server" AllowExpandCollapse="true">
            
                <bodytemplate>
                    <asp:UpdatePanel ID="ChatUpdatePanel" runat="server" UpdateMode="Always" rendermode="block">
                        <ContentTemplate>
                            <table width="100%" style="border-style: solid; border-color: Black; border-width: 1px;">
                                <tr>
                                    <td>
                                        Chat Users
                                    </td>
                                    <td>
                                        Chat
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top"style="border-style: solid; border-color: Black; border-width: 1px;">
                                        <div id="Div1" style="width: 100px; height: 340px; overflow: auto;">                                    
                                            <asp:BulletedList displaymode="Text" ID="ChattersBulletedList" runat="server" />                                    
                                        </div>                                             
                                    </td>
                                    <td valign="top"style="border-style: solid; border-color: Black; border-width: 1px;">
                                        <div id="ChatText" style="width: 440px; height: 340px; overflow: auto;">
                                            <asp:BulletedList runat="server" displaymode="Text" ID="ChatMessageList" />
                                            <asp:gridview id="uxtest" runat="server"></asp:gridview>
                                        </div>                                 
                                    </td>
                                </tr>
                            </table>                            
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="SendButton" EventName="Click" />
                            <asp:AsyncPostBackTrigger ControlID="ChatTextTimer" EventName="Tick" />
                        </Triggers>
                    </asp:UpdatePanel>
                    Chat Text<br/>
                    <asp:TextBox ID="NewMessageTextBox" Columns="50" runat="server" /><asp:Button EnableViewState="false" ID="SendButton" Text="Send" runat="server" OnClick="SendButton_Click" /><br />
                    Auto Scroll&nbsp;<input id="ckAutoScroll" type="checkbox" checked /><br />
                    <asp:Timer runat="server" ID="ChatTextTimer" Interval="1000" />                
                </bodytemplate>
            </container:templatedcontainer>            
        </td>        
    </tr>
</table>                        

        <script type="text/javascript">
            function _SetChatTextScrollPosition()
            {
                if(document.getElementById('ckAutoScroll').checked==true)
                {
                    var chatText = document.getElementById("ChatText");
                    chatText.scrollTop = chatText.scrollHeight;
                }                    
                    window.setTimeout("_SetChatTextScrollPosition()", 1);
            }

            window.onload = function()
            {
                _SetChatTextScrollPosition();
            }      
            
            //Key Press Checks start            
            function document.onkeydown()
            {
                //block F5, no refresh
                if(window.event.keyCode==116)
                {
                    event.keyCode=0;
                    event.returnValue = false;
                }
                //block Ctrl + R, no refresh
                if ((window.event.ctrlKey)&&(window.event.keyCode==82))
                {
                    event.keyCode=0;
                    event.returnValue = false;
                }
                //if enter pressed, press Tab key instead
                if (event.keyCode==13) 
                {
                    event.keyCode=9;
                    event.returnValue = false; 
                }
                //block ctrl + N, no new window
                if ((window.event.ctrlKey)&&(window.event.keyCode==78))
                {
                    event.keyCode=0;
                    event.returnValue = false;
                }
            }    
            //Key Press Checks end
                                        
            //No right click code start
            var oLastBtn=0;
            bIsMenu = false;
            
            if (window.Event) 
            {
                document.captureEvents(Event.MOUSEUP); 
            }
            function nocontextmenu()
            { 
                event.cancelBubble = true 
                event.returnValue = false; 
                return false; 
            } 
            function norightclick(e) 
            { 
                if (window.Event) 
                { 
                if (e.which !=1) 
                    return false; 
                } 
                else 
                if (event.button !=1) 
                { 
                    event.cancelBubble = true 
                    event.returnValue = false; 
                    return false; 
                } 
            } 
            document.oncontextmenu = nocontextmenu; 
            document.onmousedown = norightclick; 
            //no right click end                    
        </script>

</asp:Content>

